﻿<?php 
header('Content-Type: text/html; charset=utf-8');
$cookie_file = tempnam('./temp', 'cookie');
$timeout = 10;	
function calc($m,$n,$x){
    $errors=array(
            '被除数不能为零',
            '负数没有平方根'
    );
    switch($x){
            case 'add':
                    $t=bcadd($m,$n);
                    break;
            case 'sub':
                    $t=bcsub($m,$n);
                    break;
            case 'mul':
                    $t=bcmul($m,$n);
                    break;
            case 'div':
                    if($n!=0){
                            $t=bcdiv($m,$n);
                    }else{
                            return $errors[0];
                    }
                    break;
            case 'pow':
                    $t=bcpow($m,$n);
                    break;
            case 'mod':
                    if($n!=0){
                            $t=bcmod($m,$n);
                    }else{
                            return $errors[0];
                    }
                    break;
            case 'sqrt':
                    if($m>=0){
                            $t=bcsqrt($m);
                    }else{
                            return $errors[1];
                    }
                    break;
    }
    $t=preg_replace("/\..*0+$/",'',$t);
    return $t;
}
	
$Telname = "18610004265";	//玩客云电话号码
$TelID = "zhiliao520";		//玩客登陆密码

$strmd5 =  md5($TelID);
$ping1 = mb_substr( $strmd5, 0, 2, 'utf-8');
$ping2 = mb_substr( $strmd5, 8, 1, 'utf-8');
$ping3 = mb_substr( $strmd5, 3, 5, 'utf-8');
$ping4 = mb_substr( $strmd5, 2, 1, 'utf-8');
$ping5 = mb_substr( $strmd5, 9, 8, 'utf-8');
$ping6 = mb_substr( $strmd5, 27, 1, 'utf-8');
$ping7 = mb_substr( $strmd5, 18, 9, 'utf-8');
$ping8 = mb_substr( $strmd5, 17, 1, 'utf-8');
$ping9 = mb_substr( $strmd5, 28, 4, 'utf-8');
$getmd5 = $ping1.$ping2.$ping3.$ping4.$ping5.$ping6.$ping7.$ping8.$ping9;

$login_url="https://account.onethingpcs.com/user/login?appversion=1.4.8";
//$ping1 = mb_substr( $strmd5, 0, 2, 'utf-8');
//deviceid = md5(phone)[0:16].upper()//转化为大写
//$tel='15011052993';
$telphone = mb_substr(md5($Telname), 0, 16, 'utf-8');
$deviceid = strtoupper($telphone);
$imeiid = calc(''.$Telname.'','2','pow');
$imeiid = mb_substr($imeiid, 0, 14, 'utf-8');
$body = 'account_type=4&deviceid='.$deviceid.'&imeiid='.$imeiid.'&phone='.$Telname.'&pwd='.md5($getmd5).'&key=';
$sign = md5($body);
$post_data = array ("deviceid" => "".$deviceid."","imeiid" => "".$imeiid."","phone" => "".$Telname."","pwd" => "".md5($getmd5)."","account_type" => "4","sign" => "".$sign."");//这是提交表单
$headers = array(
       "User-Agent: Mozilla/5.0",
       "Accept: text/html",
//	'CLIENT-IP:'.$cip, 
//	'X-FORWARDED-FOR:'.$xip 
  "Referer: http://red.xunlei.com"
  );
//提交登录表单请求
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $login_url);
curl_setopt($ch,CURLOPT_HEADER,0);//1将头文件的信息作为数据流输出 正常情况是0关闭
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout); //add 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);// post的变量
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file); //存储提交后得到的cookie数据
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
$output = curl_exec($ch);
curl_close($ch);
echo iconv('gbk', 'UTF-8', $output);
$obj = json_decode($output,true);//解析json 
$getcode = $obj['iRet'];//获取code
if($getcode=="0"){
echo("<div><h3>iRet：".$getcode.", userid:".$obj['data']['userid']."sMsg ".$obj['sMsg']." </h3></div>");
//省去登录成功的信息进行提交 获取近期收益


}else{
exit("<div><h3>错误代码：".$getcode.", 提示："."sMsg ".$obj['sMsg']." </h3></div>");
}
$post_income = array ("page" => "0","appversion" => "1.4.8","sign" => "".$sign."");//这是提交表单
$url="https://account.onethingpcs.com/wkb/income-history";
$ch=curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_income);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file); //使用提交后得到的cookie数据做参数
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
$contents=curl_exec($ch);
curl_close($ch);
//转码显示
echo iconv('gbk', 'UTF-8', $contents);
$objin = json_decode($contents,true);//解析json 
$getincode = $objin['iRet'];//获取code




//提币记录
$url="https://account.onethingpcs.com/wkb/outcome-history?page=0";
$ch=curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file); //使用提交后得到的cookie数据做参数
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
$outcomes=curl_exec($ch);
curl_close($ch);
echo iconv('gbk', 'UTF-8', $outcomes);
$objout = json_decode($outcomes,true);//解析json 
$getocode = $objout['iRet'];//获取code







?>